<template>
  <div style="text-align: left;margin-left: 30px">
    <div style="margin: 20px auto 20px">
      <el-page-header @back="goBack" content="创建流程接口用例"></el-page-header>
    </div>
    <div class="dialog-footer" style="display:flex;margin-top: 20px">
      <div style="flex: 2">
        <!--用例信息-->
        <el-button type="primary" size='small' @click="caseProcessAdd('ruleForm')">提 交</el-button>
        <el-tabs value="first" type="card" style="margin: 20px 30px">
          <!--用例信息-->
          <el-tab-pane label="用例信息" name="first">
            <el-form :model="caseInfo" inline label-width="80px" label-position="right" :rules="rules" ref="ruleForm">
              <el-form-item label="用例名称">
                <el-input v-model="caseInfo.name" clearable style="width: 200px"></el-input>
              </el-form-item>
              <el-form-item label="所属项目" prop="belong_project_id">
                <el-select style="width: 200px" v-model="caseInfo.belong_project_id" filterable placeholder="请选择项目">
                  <el-option v-for="item in projectList" :key="item.pk" :label="item.fields.project_name" :value="item.pk"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="可选模块" prop="belong_module_id">
                <el-select style="width: 200px" v-model="caseInfo.belong_module_id" filterable placeholder="请选择模块">
                  <el-option v-for="item in moduleList" :key="item.pk" :label="item.fields.module_name" :value="item.pk"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="Base_url">
                <el-input v-model="caseInfo.base_url" clearable style="width: 300px">
                  <template slot="prepend">Http://</template>
                </el-input>
              </el-form-item>
            </el-form>
          </el-tab-pane>
          <!--用例公共变量-->
          <el-tab-pane label="公共变量" name="second">
            <el-button type="primary" size='small' style="margin: 10px 5px" @click="addCommonVariables">添加变量</el-button>
            <h3 style="margin: 5px auto 10px ">公共变量(Variables):</h3>
            <el-table :data="caseInfo.variables" @selection-change="selectChange">
              <!--Variables请求数据选择项-->
              <el-table-column type="selection"></el-table-column>
              <!--Variables请求数据key值-->
              <el-table-column label="变量名称">
                <template slot-scope="scope">
                  <el-input style="width: 300px" v-model="scope.row.Key"></el-input>
                </template>
              </el-table-column>
              <!--Variables请求数据类型-->
              <el-table-column label="变量类型">
                <template slot-scope="scope">
                  <el-select v-model="scope.row.Type">
                    <el-option v-for="item in dataTypes" :label="item" :value="item"></el-option>
                  </el-select>
                </template>
              </el-table-column>
              <!--Variables请求数据value值-->
              <el-table-column label="变量值">
                <template slot-scope="scope">
                  <el-input v-model="scope.row.Value" style="width: 300px"></el-input>
                </template>
              </el-table-column>
              <!--Variables请求数据操作-->
              <el-table-column label="操作">
                <template slot-scope="scope">
                  <el-button @click.native.prevent="deleteRow(scope.$index,caseInfo.variables)" type="text" size="small">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
        </el-tabs>
        <!--测试步骤信息-->
        <div>
          <h3 class="interval">步骤(Steps):</h3>
          <el-button class='interval' type="primary" size='small' @click="stepAdd()">添加步骤</el-button>
          <el-table :data="caseInfo.caseSteps">
            <el-table-column type="expand">
              <template slot-scope="props">
                <el-tabs value="first" type="card">
                  <!--变量信息-->
                  <el-tab-pane label="私有变量" name="first">
                    <!--Variables信息-->
                    <div class="interval">
                      <el-button type="primary" size='small' @click="addVariables(props.$index,caseInfo.caseSteps)">添加私有变量</el-button>
                      <el-button type="primary" size='small' @click="delVariables(props.$index,caseInfo.caseSteps)">批量删除</el-button>
                    </div>
                    <div>
                      <h3 class="interval">私有变量(Variables):</h3>
                      <el-table :data="props.row.variables" @selection-change="selectChange">
                        <!--Variables请求数据选择项-->
                        <el-table-column type="selection"></el-table-column>
                        <!--Variables请求数据key值-->
                        <el-table-column label="变量名称">
                          <template slot-scope="scope">
                            <el-input style="width: 300px" v-model="scope.row.Key"></el-input>
                          </template>
                        </el-table-column>
                        <!--Variables请求数据类型-->
                        <el-table-column label="变量类型">
                          <template slot-scope="scope">
                            <el-select v-model="scope.row.Type">
                              <el-option v-for="item in dataTypes" :label="item" :value="item"></el-option>
                            </el-select>
                          </template>
                        </el-table-column>
                        <!--Variables请求数据value值-->
                        <el-table-column label="变量值">
                          <template slot-scope="scope">
                            <el-input v-model="scope.row.Value" style="width: 300px"></el-input>
                          </template>
                        </el-table-column>
                        <!--Variables请求数据操作-->
                        <el-table-column label="操作">
                          <template slot-scope="scope">
                            <el-button @click.native.prevent="deleteRow(scope.$index,props.row.variables)" type="text" size="small">删除</el-button>
                          </template>
                        </el-table-column>
                      </el-table>
                    </div>
                  </el-tab-pane>
                  <!--请求数据信息-->
                  <el-tab-pane label="请求信息" name="second">
                    <el-form inline>
                      <div class="interval">
                        <el-button type="primary" size='small' @click="addData(props.$index,caseInfo.caseSteps)">添加Data</el-button>
                        <el-button type="primary" size='small' @click="delData(props.$index,caseInfo.caseSteps)">批量删除Data</el-button>
                        <el-button type="primary" size='small' @click="addHeaders(props.$index,caseInfo.caseSteps)">添加Headers</el-button>
                        <el-button type="primary" size='small' @click="delHeaders(props.$index,caseInfo.caseSteps)">批量删除Headers</el-button>
                      </div>
                      <el-form-item label="Url">
                        <el-input v-model="props.row.request.url" placeholder="请输入url，如'/login'"></el-input>
                      </el-form-item>
                      <el-form-item label="Method">
                        <el-select v-model="props.row.request.method">
                          <el-option v-for="item in reqMethods" :label="item" :value="item"></el-option>
                        </el-select>
                      </el-form-item>
                    </el-form>
                    <!--data请求数据-->
                    <div>
                      <h3>Data(json):</h3>
                      <el-table :data="props.row.request.json" @selection-change="selectChange">
                        <!--data请求数据选择项-->
                        <el-table-column type="selection"></el-table-column>
                        <!--data请求数据key值-->
                        <el-table-column label="Data名称">
                          <template slot-scope="scope">
                            <el-input style="width: 300px" v-model="scope.row.Key"></el-input>
                          </template>
                        </el-table-column>
                        <!--data请求数据类型-->
                        <el-table-column label="Data类型">
                          <template slot-scope="scope">
                            <el-select v-model="scope.row.Type">
                              <el-option v-for="item in dataTypes" :label="item" :value="item"></el-option>
                            </el-select>
                          </template>
                        </el-table-column>
                        <!--data请求数据value值-->
                        <el-table-column label="Data值">
                          <template slot-scope="scope">
                            <el-input v-model="scope.row.Value" style="width: 300px"></el-input>
                          </template>
                        </el-table-column>
                        <!--data请求数据操作-->
                        <el-table-column label="操作">
                          <template slot-scope="scope">
                            <el-button @click.native.prevent="deleteRow(scope.$index,props.row.request.json)" type="text" size="small">删除</el-button>
                          </template>
                        </el-table-column>
                      </el-table>
                    </div>
                    <!--headers请求数据-->
                    <div>
                      <h3>Headers:</h3>
                      <el-table :data="props.row.request.headers" @selection-change="selectChange">
                        <!--headers请求数据选择项-->
                        <el-table-column type="selection"></el-table-column>
                        <!--headers请求数据key值-->
                        <el-table-column label="Key">
                          <template slot-scope="scope">
                            <el-input style="width: 300px" v-model="scope.row.Key"></el-input>
                          </template>
                        </el-table-column>
                        <!--headers请求数据value值-->
                        <el-table-column label="Value">
                          <template slot-scope="scope">
                            <el-input v-model="scope.row.Value" style="width: 300px"></el-input>
                          </template>
                        </el-table-column>
                        <!--headers   请求数据操作-->
                        <el-table-column label="操作">
                          <template slot-scope="scope">
                            <el-button @click.native.prevent="deleteRow(scope.$index,props.row.request.headers)" type="text" size="small">删除</el-button>
                          </template>
                        </el-table-column>
                      </el-table>
                    </div>
                  </el-tab-pane>
                  <!--数据提取/断言等信息-->
                  <el-tab-pane label="数据提取/断言" name="third">
                    <div class='interval'>
                      <el-button type="primary" size='small' @click="addExtract(props.$index,caseInfo.caseSteps)">添加数据提取</el-button>
                      <el-button type="primary" size='small' @click="delExtract(props.$index,caseInfo.caseSteps)">批量删除数据提取</el-button>
                      <el-button type="primary" size='small' @click="addValidate(props.$index,caseInfo.caseSteps)">添加断言</el-button>
                      <el-button type="primary" size='small' @click="delValidate(props.$index,caseInfo.caseSteps)">删除断言</el-button>
                    </div>
                    <!--extract信息-->
                    <div>
                      <h3>数据提取(Extract):</h3>
                      <el-table :data="props.row.extract" @selection-change="selectChange">
                        <el-table-column type="selection"></el-table-column>
                        <el-table-column label="Key">
                          <template slot-scope="scope">
                            <el-input style="width: 300px" v-model="scope.row.Key"></el-input>
                          </template>
                        </el-table-column>
                        <el-table-column label="Type">
                          <template slot-scope="scope">
                            <el-select v-model="scope.row.Type">
                              <el-option v-for="item in dataTypes" :label="item" :value="item"></el-option>
                            </el-select>
                          </template>
                        </el-table-column>
                        <el-table-column label="Value">
                          <template slot-scope="scope">
                            <el-input style="width: 300px" v-model="scope.row.Value"></el-input>
                          </template>
                        </el-table-column>
                        <el-table-column label="操作">
                          <template slot-scope="scope">
                            <el-button @click.native.prevent="deleteRow(scope.$index,props.row.extract)" type="text" size="small">删除</el-button>
                          </template>
                        </el-table-column>
                      </el-table>
                    </div>
                    <!--validate信息-->
                    <div>
                      <h3>断言(Validate):</h3>
                      <el-table :data="props.row.validate" @selection-change="selectChange">
                        <el-table-column type="selection"></el-table-column>
                        <el-table-column label="检查点">
                          <template slot-scope="scope">
                            <el-input style="width: 300px" v-model="scope.row.Check"></el-input>
                          </template>
                        </el-table-column>
                        <el-table-column label="判断类型">
                          <template slot-scope="scope">
                            <el-select v-model="scope.row.Comparator">
                              <el-option v-for="item in comparators" :label="item" :value="item"></el-option>
                            </el-select>
                          </template>
                        </el-table-column>
                        <el-table-column label="预期值类型">
                          <template slot-scope="scope">
                            <el-select v-model="scope.row.Type">
                              <el-option v-for="item in dataTypes" :label="item" :value="item"></el-option>
                            </el-select>
                          </template>
                        </el-table-column>
                        <el-table-column label="预期值">
                          <template slot-scope="scope">
                            <el-input style="width: 300px" v-model="scope.row.Expect"></el-input>
                          </template>
                        </el-table-column>
                        <el-table-column label="操作">
                          <template slot-scope="scope">
                            <el-button @click.native.prevent="deleteRow(scope.$index,props.row.validate)" type="text" size="small">删除</el-button>
                          </template>
                        </el-table-column>
                      </el-table>
                    </div>
                  </el-tab-pane>
                  <!--用例parameters/hooks等信息-->
                  <el-tab-pane label="parameters/hooks" name="forth">
                    <div class="interval">
                      <el-button type="primary" size='small' @click="addParameters(props.$index,caseInfo.caseSteps)">add parameters</el-button>
                      <el-button type="primary" size='small' @click="delParameters(props.$index,caseInfo.caseSteps)">del parameters</el-button>
                      <el-button type="primary" size='small' @click="addHooks(props.$index,caseInfo.caseSteps)">add hooks</el-button>
                      <el-button type="primary" size='small' @click="delHooks(props.$index,caseInfo.caseSteps)">del hooks</el-button>
                    </div>
                    <!--Parameters信息-->
                    <div>
                      <h3>parameters:</h3>
                      <el-table :data="props.row.parameters" @selection-change="selectChange">
                        <!--parameters请求数据选择项-->
                        <el-table-column type="selection"></el-table-column>
                        <!--parameters请求数据key值-->
                        <el-table-column label="Key">
                          <template slot-scope="scope">
                            <el-input style="width: 300px" v-model="scope.row.Key"></el-input>
                          </template>
                        </el-table-column>
                        <!--parameters请求数据value值-->
                        <el-table-column label="Value">
                          <template slot-scope="scope">
                            <el-input v-model="scope.row.Value" style="width: 300px"></el-input>
                          </template>
                        </el-table-column>
                        <!--parameters请求数据操作-->
                        <el-table-column label="操作">
                          <template slot-scope="scope">
                            <el-button @click.native.prevent="deleteRow(scope.$index,props.row.parameters)" type="text" size="small">删除</el-button>
                          </template>
                        </el-table-column>
                      </el-table>
                    </div>
                    <!--hooks信息-->
                    <div>
                      <h3>hooks:</h3>
                      <el-table :data="props.row.hooks" @selection-change="selectChange">
                        <!--hooks请求数据选择项-->
                        <el-table-column type="selection"></el-table-column>
                        <!--hooks请求数据Set_hooks值-->
                        <el-table-column label="Setup_hooks">
                          <template slot-scope="scope">
                            <el-input style="width: 300px" v-model="scope.row.setup_hooks"></el-input>
                          </template>
                        </el-table-column>
                        <!--hooks请求数据Teardown_hooks值-->
                        <el-table-column label="Teardown_hooks">
                          <template slot-scope="scope">
                            <el-input v-model="scope.row.teardown_hooks" style="width: 300px"></el-input>
                          </template>
                        </el-table-column>
                        <!--hooks请求数据操作-->
                        <el-table-column label="操作">
                          <template slot-scope="scope">
                            <el-button @click.native.prevent="deleteRow(scope.$index,props.row.hooks)" type="text" size="small">删除</el-button>
                          </template>
                        </el-table-column>
                      </el-table>
                    </div>
                  </el-tab-pane>
                </el-tabs>
              </template>
            </el-table-column>
            <el-table-column label="测试步骤">
              <template slot-scope="scope">
                <el-input v-model="scope.row.stepName" style="width:300px"></el-input>
              </template>
            </el-table-column>
            <el-table-column label="操作">
              <template slot-scope="scope">
                <el-button @click.native.prevent="runRow(scope.$index, caseInfo.caseSteps)" type="text" size="small">运行</el-button>
                <el-button @click.native.prevent="deleteRow(scope.$index,caseInfo.caseSteps)" type="text" size="small">删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <!--用例配置-->
      <div style="flex: 1;text-align: left; margin: 33px 20px">
        <el-tabs value="first" type="card" style="margin-top: 20px">
          <!--debugtalk编辑区-->
          <el-tab-pane label="Debugtalk" name="first">
            <label>
              <textarea style="background: black;color: white;width: 100%" rows="30" cols="40" v-model="debugtalkInfo.debugtalk"></textarea>
            </label>
          </el-tab-pane>
          <!--.env编辑区-->
          <el-tab-pane label="Env" name="second">
            <label>
              <textarea style="background: black;color: white;width: 100%" rows="30" cols="40" v-model="envInfo.content"></textarea>
            </label>
          </el-tab-pane>
        </el-tabs>
      </div>
    </div>
  </div>
</template>

<script>
import http from "../../../static/js/common"

export default {
    name: "caseAdd",
    data() {
        return {
            moduleId: "",
            projectList: [],
            moduleList: [],
            caseList: [],
            reqMethods: ["GET", "POST", "PUT", "DELETE"],
            dataTypes: ['int', 'float', 'string', 'boolean'],
            comparators: ["equals", 'contains', 'startswith', 'endswith', 'less_than'],
            selectItem: [], //选择项目
            caseInfo: {
                name: "流程接口用例01",
                typeCase: "single",
                base_url: "127.0.0.1:8000",
                belong_project_id: "",
                belong_module_id: "",
                author: "",
                variables: [
                    {
                        Key: "1234",
                        Type: "string",
                        Value: "1234",
                    }
                ],
                caseSteps: [
                    {
                        stepName: "第一步",
                        request: {
                            url: "/api/login/",
                            method: "GET",
                            headers: [
                                {
                                    Key: "Content-Type",
                                    Value: "application/json",
                                }
                            ],
                            json: [
                                {
                                    Key: "username",
                                    Type: "string",
                                    Value: "admin",
                                },
                                {
                                    Key: "password",
                                    Type: "string",
                                    Value: "123456",
                                }
                            ],
                        },
                        include: [],
                        validate: [
                            {
                                Check: "status_code",
                                Comparator: "equals",
                                Type: "int",
                                Expect: "200",
                            }
                        ],
                        extract: [
                            {
                                Key: "1234",
                                Type: "string",
                                Value: "content.url",
                            }
                        ],
                        variables: [
                            {
                                Key: "1234",
                                Type: "string",
                                Value: "1234",
                            }
                        ],
                        parameters: [
                            {
                                Key: "1234",
                                Value: "1234",
                            }
                        ],
                        hooks: [
                            {
                                setup_hooks: "",
                                teardown_hooks: "",
                            }
                        ]
                    }
                ]
            },
            rules: {
                belong_project_id: [
                    {required: true, message: '请选择项目', trigger: 'blur'},
                ],
                belong_module_id: [
                    {required: true, message: '请选择模块', trigger: 'blur'},
                ],
            },
            debugtalkInfo: {
                id: '',
                belong_module: '',
                belong_project: '',
                debugtalk: '',
            },
            envInfo: {
                id: '',
                belong_module: '',
                belong_project: '',
                content: '',
            },
        }
    },
    methods: {
        getProjectList() {
            //获取项目信息
            http.get("/api/projectList/", {params: {'moduleId': this.moduleId, 'type': 'caseAdd'}})
                .then(res => {
                    console.log('获取项目：');
                    console.log(res.data.projectList);
                    this.projectList = res.data.projectList;
                })
        },
        getModuleList(projectId) {
            //获取项目信息
            http.get("/api/moduleList/", {params: {'projectId': projectId, 'moduleId': this.moduleId, 'type': 'caseAdd'}})
                .then(res => {
                    console.log('获取模块：');
                    console.log(res.data.moduleList);
                    this.moduleList = res.data.moduleList;
                })
        },
        getCaseList() {
            http.get("/api/caseList/")
                .then(res => {
                    this.caseList = res.data.caseList;
                    console.log('获取用例：');
                    console.log(this.caseList)
                })
                .catch(error => {
                    console.log(error)
                })
        },
        deleteRow(index, rows) {
            rows.splice(index, 1)
        },
        stepAdd() {
            this.caseInfo.caseSteps.push(
                {
                    stepName: "测试步骤",
                    request: {
                        url: "/api/login/",
                        method: "GET",
                        headers: [
                            {
                                Key: "Content-Type",
                                Value: "application/json",
                            }
                        ],
                        json: [
                            {
                                Key: "username",
                                Type: "string",
                                Value: "admin",
                            },
                            {
                                Key: "password",
                                Type: "string",
                                Value: "123456",
                            }
                        ],
                    },
                    include: [],
                    validate: [
                        {
                            Check: "status_code",
                            Comparator: "equals",
                            Type: "int",
                            Expect: "200",
                        }
                    ],
                    extract: [
                        {
                            Key: "1234",
                            Value: "1234",
                        }
                    ],
                    variables: [
                        {
                            Key: "1234",
                            Type: "string",
                            Value: "1234",
                        }
                    ],
                    parameters: [
                        {
                            Key: "1234",
                            Value: "1234",
                        }
                    ],
                    hooks: [
                        {
                            setup_hooks: "",
                            teardown_hooks: "",
                        }
                    ]
                }
            )
        },
        addData(index, rows) {
            rows[index].request.json.push(
                {
                    Key: "1234",
                    Type: "string",
                    Value: "1234",
                }
            )
        },
        delData(index, rows) {
            console.log("删除选择项目：");
            for (let i = 0; i < this.selectItem.length; i++) {
                let index1 = rows[index].request.json.indexOf(this.selectItem[i]);
                if (index1 > -1) {
                    rows[index].request.json.splice(index1, 1);
                }
            }
        },
        addValidate(index, rows) {
            rows[index].validate.push(
                {
                    Check: "",
                    Comparator: "equals",
                    Type: "",
                    Expected: "",
                }
            )
        },
        delValidate(index, rows) {
            console.log("删除选择项目：");
            for (var i = 0; i < this.selectItem.length; i++) {
                var index1 = rows[index].validate.indexOf(this.selectItem[i]);
                if (index1 > -1) {
                    rows[index].validate.splice(index1, 1);
                }
            }
        },
        addCommonVariables() {
            this.caseInfo.variables.push(
                {
                    Key: "1234",
                    Type: "string",
                    Value: "1234",
                }
            )
        },
        addVariables(index, rows) {
            rows[index].variables.push(
                {
                    Key: "1234",
                    Type: "string",
                    Value: "1234",
                }
            )
        },
        delVariables(index, rows) {
            console.log("删除variables：");
            for (let i = 0; i < this.selectItem.length; i++) {
                let index1 = rows[index].variables.indexOf(this.selectItem[i]);
                if (index1 > -1) {
                    rows[index].variables.splice(index1, 1);
                }
            }
        },
        addParameters(index, rows) {
            rows[index].parameters.push(
                {
                    Key: "1234",
                    Value: "1234",
                }
            )
        },
        delParameters(index, rows) {
            console.log("删除Parameters：");
            for (let i = 0; i < this.selectItem.length; i++) {
                let index1 = rows[index].parameters.indexOf(this.selectItem[i]);
                if (index1 > -1) {
                    rows[index].parameters.splice(index1, 1);
                }
            }
        },
        addHeaders(index, rows) {
            rows[index].request.headers.push({
                Key: "1234",
                Value: "1234",
            })
        },
        delHeaders(index, rows) {
            console.log("删除选删除请求头信息：");
            for (let i = 0; i < this.selectItem.length; i++) {
                let index1 = rows[index].request.headers.indexOf(this.selectItem[i]);
                if (index1 > -1) {
                    rows[index].request.headers.splice(index1, 1);
                }
            }
        },
        addExtract(index, rows) {
            rows[index].extract.push({
                Key: "1234",
                Value: "1234",
            })
        },
        delExtract(index, rows) {
            console.log("删除extract信息：");
            for (let i = 0; i < this.selectItem.length; i++) {
                let index1 = rows[index].extract.indexOf(this.selectItem[i]);
                if (index1 > -1) {
                    rows[index].extract.splice(index1, 1);
                }
            }
        },
        addHooks(index, rows) {
            rows[index].hooks.push(
                {
                    setup_hooks: "",
                    teardown_hooks: ""
                }
            )
        },
        delHooks(index, rows) {
            console.log("删除hooks信息：");
            for (let i = 0; i < this.selectItem.length; i++) {
                let index1 = rows[index].hooks.indexOf(this.selectItem[i]);
                if (index1 > -1) {
                    rows[index].hooks.splice(index1, 1);
                }
            }
        },
        selectChange(val) {
            this.selectItem = val;
            console.log("获取选择项目：");
            console.log(this.selectItem)

        },
        caseProcessAdd(formName) {
            console.log("添加用例");
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    http.post('api/caseAdd/', {'type': 'process', 'caseInfo': this.caseInfo, 'debugTalkInfo': this.debugtalkInfo, 'envInfo': this.envInfo})
                        .then(res => {
                            if (res.data.msgCode === "1") {
                                console.log("添加用例成功");
                                this.$router.back()
                            }
                        })
                        .catch(error => {
                            console.log(error)
                        })
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        },
        //获取debugtalk内容
        getDebugtalkInfo(moduleId) {
            this.$axios.get('/api/debugtalk/', {params: {'moduleId': moduleId}})
                .then(res => {
                    console.log('获取debugtalk信息：');
                    console.log(res.data);
                    this.debugtalkInfo = res.data.debugtalkInfo
                });
        },
        //获取env内容
        getEnvInfo(moduleId) {
            this.$axios.get('/api/envInfo/', {params: {'moduleId': moduleId}})
                .then(res => {
                    console.log('获取env信息：');
                    console.log(res.data);
                    this.envInfo = res.data.envInfo
                });
        },
        goBack() {
            console.log('go back');
            this.$router.back();
        }
    },
    watch: {
        "caseInfo.belong_project_id":
            {
                handler(newVal, oldVal) {
                    console.log(newVal);
                    console.log(oldVal);
                    this.getModuleList(newVal)
                }
            },
        deep: true,
    },
    created() {
        this.moduleId = this.$route.query.moduleId;
        this.getProjectList();
        this.getCaseList();
        if (this.$route.fullPath.indexOf('moduleId') !== -1) {
            this.getDebugtalkInfo(this.moduleId);
            this.getEnvInfo(this.moduleId);
        }
    },
}
</script>

<style scoped>
  .interval {
    margin: 10px auto;
  }
</style>
